MNT: Add more defaults to the stubs#1728
MNT: Add more defaults to the stubs#1728loicdiridollou wants to merge 1 commit intopandas-dev:mainfrom
Conversation
| cls, | ||
| value: str | float | Timedelta | Tick | timedelta | np.timedelta64 = ..., | ||
| unit: TimeDeltaUnitChoices = ..., | ||
| unit: TimeDeltaUnitChoices = "ns", |
There was a problem hiding this comment.
In Timedelta.__new__, the unit parameter actually defaults to None at runtime, although the docstring mentions "ns". Using None allows the constructor to handle input resolution correctly.
Ground Truth: timedeltas.pyx#L2147
Gemini 3 created, I verified
| columns: list[str] | None = None, | ||
| *, | ||
| chunksize: int, | ||
| dtype_backend: DtypeBackend | NoDefault = ..., |
There was a problem hiding this comment.
The read_sql_table function does not enforce keyword-only arguments for chunksize in the pandas 3.0 source. The * should be removed to maintain positional compatibility.
Ground Truth: io/sql.py#L257
Gemini 3 created, I verified
| sharey: bool = ..., | ||
| layout: tuple[int, int] = ..., | ||
| figsize: tuple[float, float] = ..., | ||
| sharex: bool = False, |
There was a problem hiding this comment.
For sharex, sharey, and legend, the runtime often uses None as a default to trigger context-aware logic (e.g., sharex depends on whether an ax is passed). Setting these to False in the stubs might be misleading. I suggest using None where the runtime signature does.
Ground Truth: plotting/_core.py#L1112
Signed, Gemini 3
There was a problem hiding this comment.
Edit: maybe github.com/pandas-dev/pandas/blob/main/pandas/plotting/_core.py#L1050, where it says None for sharex, but False for sharey. This is confusing.
| self, | ||
| *, | ||
| axis: AxisInt | None = None, | ||
| dtype: DtypeArg | None = None, |
There was a problem hiding this comment.
These reduction methods (sum, std, etc.) can return NaT (represented as NaTType) when skipna=False or on empty inputs. The return type should be expanded to Timedelta | NaTType.
Ground Truth: core/arrays/timedeltas.py#L367 (via _box_func)
Gemini 3 created, I verified
There was a problem hiding this comment.
I don't think we should return Timedelta | NaTType in this case because it will force users to do a cast when they know the result is valid. I'd be OK with an overload with skipna=False that returned Timedelta | NaTType
| storage_options: StorageOptions = None, | ||
| dtype_backend: DtypeBackend | NoDefault = ..., | ||
| engine: Literal["ujson"] = ..., | ||
| engine: Literal["ujson"] = "ujson", |
There was a problem hiding this comment.
The engine parameter supports more than just "ujson". It should use the JSONEngine type alias to include "pyarrow".
Ground Truth: io/json/_json.py#L535
Gemini 3 created, I verified
assert_type()to assert the type of any return value)AGENTS.md.About 500 instances of ellipsis removed and replaced with the proper default value so help with IDE hovering.
It remains around 1900 instances of ellipsis, we won't be able to clean them all since some use
lib.no_defaultbut we should be able to do some good progress there.